package com.dex4d.db;

import android.arch.persistence.room.Dao;
import android.arch.persistence.room.Delete;
import android.arch.persistence.room.Insert;
import android.arch.persistence.room.Query;
import android.arch.persistence.room.Update;

import com.dex4d.model.AssetModel;

import java.util.Collection;
import java.util.List;

import static android.arch.persistence.room.OnConflictStrategy.REPLACE;

/**
 * Created by chengyuchun on 2018/10/30.
 */
@Dao
public interface AssetDao {
    @Query("SELECT * FROM asset")
    List<AssetModel> getAll();

    @Insert(onConflict = REPLACE)
    long insert(AssetModel assetModel);

    @Insert
    void insertAll(Collection<AssetModel> assetModels);

    @Update(onConflict = REPLACE)
    int update(AssetModel assetModel);

    @Delete
    void delete(AssetModel assetModel);

    @Query("SELECT * FROM asset WHERE symbol = (:symbol)")
    AssetModel getAsset(String symbol);
}
